/* -*- C++ -*- */

//=============================================================================
/*
 * @author Feloweria <380374483@qq.com>
 * Copyright (C) Feloweria
 * 
 * $ID 2013-06-27 10:38:21 AM
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @version 1.0
 */
//=============================================================================

#ifndef FELOWRIA_THREAD_MUTEX_INCLUDE
#define FELOWRIA_THREAD_MUTEX_INCLUDE

#include "Felowria.h"
#include "Base/Type.h"
#include "Base/TimeValue.h"

#ifdef __LINUX__
	#include <pthread.h>
#endif


#ifdef __WINDOWS__
	#include <windows.h>
#endif


FELOWRIA_BEGIN

class DLL_EXPORT ThreadMutex
{	
public:
	ThreadMutex();
	~ThreadMutex();
	
public:
    void Lock();
	void UnLock();

public:	
    bool TryLock();
	
protected:

#ifdef __LINUX__
	pthread_mutex_t mutex;
#endif
	
#ifdef __WINDOWS__
	CRITICAL_SECTION mutex;
#endif
};//class ThreadMutex

FELOWRIA_END

#endif //FELOWRIA_THREAD_MUTEX_INCLUDE
